Skip to main content
Version: 1.3.0

Translation API Documentation

Endpoint

  • Method: POST
  • Path: https://api.kadal.ai/translation/api/v1/text
  • Summary: Translates text into a selected target language using AI models.

Description

This endpoint translates text into a specified target language, such as Arabic, Chinese, French, Hindi, Spanish, and more. The AI model (e.g., gpt-4o or gpt-4o-mini) can be selected to balance translation quality and speed.

Request

  • Content-Type: multipart/form-data

Payload

ParameterDescriptionData TypeAllowed ValuesRequired
source_textText to translateStringyes
modelAI model used for translationStringgpt-4o, gpt-4o-miniyes
target_languageTarget language for translationStringArabic, Chinese, Dari, English, French, Hindi, Kannada, Korean, Pashto, Spanish, Turkishyes

Response

{
"status_code": 200,
"message": "Success: Translation generated successfully.",
"translation": "Translated text here"
}

Error Responses

Status CodeMessageDescription
404Not foundModel not found - Invalid model

Usage

import requests

# Define the API endpoint and the payload
url = "https://api.kadal.ai/translation/api/v1/text"
token = "your_token_here"

headers = {
"accept": "application/json",
"Authorization": f"Bearer {token}",
"Content-Type": "application/x-www-form-urlencoded"
}

data = {
"source_text": "Hello, How are you?",
"target_language": "Hindi",
"model": "gpt-4o-mini"
}

# Make the POST request
response = requests.post(url, headers=headers, data=data)

# Print the response
if response.status_code == 200:
print("Response Data:", response.json())
else:
print("Failed to call the API. Status Code:", response.status_code)
print("Response Text:", response.text)